#include <bits/stdc++.h>
#define ll long long
using namespace std;

const int Maxn=2e6+7;
int n,k;
vector<int>e[Maxn];

bool tag;
int col[30];
bool vis[30];

void dfs(int u,int len,int t){
	vis[u]=1; if(len==k and t!=1) tag=0;if(len>=k) return ;
	for(auto v:e[u]) if(!vis[v]) dfs(v,len+1,t+col[v]);
}

int main(){
	freopen("life.in","r",stdin);
	freopen("life.out","w",stdout);
	
	scanf("%d%d",&n,&k);
	for(int i=1;i<n;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		e[u].emplace_back(v);
		e[v].emplace_back(u);
	}
	
	if(n<=18){
		int ans=0;
		for(int i=0;i<(1<<n);i++){
			tag=1; memset(col,0,sizeof col);
			for(int j=0;j<n;j++) if(i>>j&1) col[j+1]=1;
			for(int j=1;j<=n;j++) memset(vis,0,sizeof vis),dfs(j,1,col[j]);
			ans+=tag;
		} 
		if(ans) cout<<"YES\n"<<ans;
		else cout<<"NO\n"<<ans;
		return 0;
	}
	
	puts("YES");
	printf("%d",k);

	return 0;
}
/*
4 2
3 4
3 1
2 3
*/
